package fwdisp.gui;


import fwdisp.gui.tabs.SettingsTab;
import fwdisp.gui.tabs.StatisticsTab;
import fwdisp.gui.tabs.TestingTab;
import fwdisp.gui.tabs.WelcomeTab;
import settings.MainSettingsManager;
import settings.collections.elements.ColorSettings;
import settings.collections.elements.PictureManager;
import imagetabpaine.ImageTabPanel;
import imagetabpaine.Tab;
import java.awt.BorderLayout;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author rbs
 */
public class MainFrame extends JFrame{

    // Contains the MainTabs: Willkommen, Log, Einstellungen, Test, Exit

    private SettingsTab settingsTab;
    private StatisticsTab statisticsTab;
    private WelcomeTab welcomeTab;
    private TestingTab testingTab;

    private PictureManager pics;

    public MainFrame() {
        MainSettingsManager.load();
        ColorSettings colorSettings = MainSettingsManager.getSetting().getColorSettings();


        pics = new PictureManager();

        ImageTabPanel mainPanel = new ImageTabPanel(colorSettings.firstRow, 100, BorderLayout.NORTH);
        
        settingsTab = new SettingsTab();
        statisticsTab = new StatisticsTab();
        welcomeTab = new WelcomeTab();
        testingTab = new TestingTab();

        mainPanel.AddTab(new Tab(welcomeTab, pics.getImage("", "fireman.png")));
        mainPanel.AddTab(new Tab(statisticsTab, pics.getImage("", "stats.png")));
        mainPanel.AddTab(new Tab(settingsTab, pics.getImage("", "settings.png")));
        mainPanel.AddTab(new Tab(testingTab, pics.getImage("", "loupe.png")));
        mainPanel.finizialize();
        

        this.setLayout(new BorderLayout());
        this.setSize(700, 700);
        //this.setExtendedState(JFrame.MAXIMIZED_BOTH);
        this.add(mainPanel, BorderLayout.CENTER);
        this.addWindowListener(new WindowListener() {
            public void windowClosing(WindowEvent we) {
                //Saving all Data...
                MainSettingsManager.save();
                //Exiting
                System.exit(0);
            }            
            public void windowClosed(WindowEvent we) {}
            
            public void windowIconified(WindowEvent we) {}
            public void windowDeiconified(WindowEvent we) {}
            public void windowActivated(WindowEvent we) {}
            public void windowDeactivated(WindowEvent we) {}
            public void windowOpened(WindowEvent we) {}
        });
        setVisible(true);

    }

}
